

/*
	This do-file runs models to fill out appendix tables and figures for the sexism paper.
	
	Note that the specific code to generate figures are in 
	"05_all_figures.R"
	

*/


use "data/CPS_state_FB_ELDCH_analytic.dta", clear 
keep if fb_sample_marrcohab==1 

* Appendix Table A1 can be found from "01_Cleaning_CPS_for_state_context.do"
* Appendix Table A2 does not need a code 

* ---------------------------------- *
* ----- Generating main sexism ----- *
* ---------------------------------- *
local varlist trcwagegap1865_a lfrategap_1865 mf60ratio_wagetrc pct_maleleg  evanpro_dum_m genroleatt_main abany_main  ///
			  femmar1824_cps badum_cps median_cps nhblack_d_cps hispan_d_cps nhother_d_cps ///
			  poverty_gap wrkhr_return
foreach var of local varlist {
	egen z_`var' = std(`var')
} 
// using 
// 1) gender wage gap
// 2) gender LFP gap 
// 3) occupational pay gap
// 4) % male legislators 
// 5) % Evangelical Protestants 
// 6) Gender role attitude 
// 7) abortion attitude 
// where 1), 2), and 3) are all using population aged 18-65 


**# Table A3, Panel A 
alpha z_trcwagegap1865_a z_lfrategap_1865 z_mf60ratio_wagetrc z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v1) // main
alpha z_poverty_gap z_wrkhr_return z_mf60ratio_wagetrc z_wrkhr_return z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v2)
alpha z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v3)
alpha z_lfrategap_1865 z_mf60ratio_wagetrc z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v4)
alpha z_trcwagegap1865_a  z_mf60ratio_wagetrc z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v5)
alpha z_trcwagegap1865_a z_lfrategap_1865 z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v6)
alpha z_trcwagegap1865_a z_lfrategap_1865 z_mf60ratio_wagetrc z_evanpro_dum_m z_genroleatt_main z_abany_main, item gen(sexism_v7)
alpha z_trcwagegap1865_a z_lfrategap_1865 z_mf60ratio_wagetrc z_pct_maleleg z_genroleatt_main z_abany_main, item gen(sexism_v8)
alpha z_trcwagegap1865_a z_lfrategap_1865 z_mf60ratio_wagetrc z_pct_maleleg z_evanpro_dum_m z_abany_main, item gen(sexism_v9)
alpha z_trcwagegap1865_a z_lfrategap_1865 z_mf60ratio_wagetrc z_pct_maleleg z_evanpro_dum_m z_genroleatt_main, item gen(sexism_v10)

forval s = 1/10 {
	qui xtreg her_share i.firstbir_fe##(c.sexism_v`s' ib1.decade c.z_median_cps c.z_nhblack_d_cps c.z_hispan_d_cps c.z_nhother_d_cps), fe vce(cluster state_a)
	est store m_exclude`s'
}

esttab m_exclude* using "tables/appen_table_a3A.csv", se r2 b(3) nogaps noomit compress label star ( + 0.1 * 0.05 ** 0.01 *** 0.001) replace

**# Table A3, Panel B
foreach context in z_trcwagegap1865_a z_lfrategap_1865 z_mf60ratio_wagetrc z_pct_maleleg z_evanpro_dum_m z_genroleatt_main z_abany_main {
	qui xtreg her_share i.firstbir_fe##(c.`context' ib1.decade c.z_median_cps c.z_nhblack_d_cps c.z_hispan_d_cps c.z_nhother_d_cps), fe vce(cluster state_a)
	est store m_`context'
}
esttab m_z_* using "tables/appen_table_a3B.csv", se r2 b(3) nogaps noomit compress label star ( + 0.1 * 0.05 ** 0.01 *** 0.001) replace


**# Table A4 is full version of table3.csv

**# Appendix Figure A1 data 
use "data/CPS_state_FB_ELDCH_analytic.dta", clear 
keep if fb_sample_marrcohab==1 

local varlist trcwagegap1865_a lfrategap_1865 mf60ratio_wagetrc pct_maleleg  evanpro_dum_m genroleatt_main abany_main  ///
			  femmar1824_cps badum_cps median_cps nhblack_d_cps hispan_d_cps nhother_d_cps ///
			  poverty_gap wrkhr_return
foreach var of local varlist {
	egen z_`var' = std(`var')
} 

keep if l_year==1 
collapse (mean) m_wagegap  = z_trcwagegap1865_a ///
		 (sem)  se_wagegap = z_trcwagegap1865_a ///
		 (mean) m_lfpgap  = z_lfrategap_1865 ///
		 (sem)  se_lfpgap = z_lfrategap_1865 ///
		 (mean) m_paygap  = z_mf60ratio_wagetrc ///
		 (sem)  se_paygap = z_mf60ratio_wagetrc ///
		 (mean) m_maleleg  = z_pct_maleleg ///
		 (sem)  se_maleleg = z_pct_maleleg ///
		 (mean) m_evanpro  = z_evanpro_dum_m ///
		 (sem)  se_evanpro = z_evanpro_dum_m ///
		 (mean) m_genrole  = z_genroleatt_main ///
		 (sem)  se_genrole = z_genroleatt_main ///
		 (mean) m_abany  = z_abany_main ///
		 (sem)  se_abany = z_abany_main, by(state_a)
save "data/results/sexism_main_components.dta", replace  

**# Appendix Figure A2 data
preserve 
keep if l_year==1 
	collapse (mean) m_wagegap  = z_trcwagegap1865_a ///
			 (sd)  sd_wagegap = z_trcwagegap1865_a ///
			 (mean) m_lfpgap  = z_lfrategap_1865 ///
			 (sd)  sd_lfpgap = z_lfrategap_1865 ///
			 (mean) m_paygap  = z_mf60ratio_wagetrc ///
			 (sd)  sd_paygap = z_mf60ratio_wagetrc ///
			 (mean) m_maleleg  = z_pct_maleleg ///
			 (sd)  sd_maleleg = z_pct_maleleg ///
			 (mean) m_evanpro  = z_evanpro_dum_m ///
			 (sd)  sd_evanpro = z_evanpro_dum_m ///
			 (mean) m_genrole  = z_genroleatt_main ///
			 (sd)  sd_genrole = z_genroleatt_main ///
			 (mean) m_abany  = z_abany_main ///
		     (sd)  sd_abany = z_abany_main, by(state_a year)

save "data/results/z_state_context_by_year.dta", replace 
restore 





